snap: pass -no-xattrs to unsquashfs unpacking files
authorZygmunt Krynicki <me@zygoon.pl>
Wed, 13 Aug 2025 13:34:32 +0000 (13:34 +0000)
committerZygmunt Krynicki <me@zygoon.pl>
Thu, 21 Aug 2025 20:46:02 +0000 (20:46 +0000)
To work correctly on systems that use SELinux and extended attributes
pass -no-xattrs when unpacking files.

Signed-off-by: Zygmunt Krynicki <me@zygoon.pl>
Gbp-Pq: Name 0005-snap-pass-no-xattrs-to-unsquashfs-unpacking-files.patch

snap/squashfs/squashfs.go

index 1e5819ed5830dade25164715132404b9b8e5e7db..018a7b9e039fc966bca472cc18c958458eb93f53 100644 (file)
@@ -202,7 +202,7 @@ func (s *Snap) Unpack(src, dstDir string) error {
        usw := newUnsquashfsStderrWriter()
 
        var output bytes.Buffer
-       cmd := exec.Command("unsquashfs", "-n", "-f", "-d", dstDir, s.path, src)
+       cmd := exec.Command("unsquashfs", "-no-xattrs", "-n", "-f", "-d", dstDir, s.path, src)
        cmd.Stderr = io.MultiWriter(&output, usw)
        if err := cmd.Run(); err != nil {
                return fmt.Errorf("cannot extract %q to %q: %v", src, dstDir, osutil.OutputErr(output.Bytes(), err))
@@ -234,7 +234,7 @@ func (s *Snap) withUnpackedFile(filePath string, f func(p string) error) error {
        defer os.RemoveAll(tmpdir)
 
        unpackDir := filepath.Join(tmpdir, "unpack")
-       if output, err := exec.Command("unsquashfs", "-n", "-i", "-d", unpackDir, s.path, filePath).CombinedOutput(); err != nil {
+       if output, err := exec.Command("unsquashfs", "-no-xattrs", "-n", "-i", "-d", unpackDir, s.path, filePath).CombinedOutput(); err != nil {
                return fmt.Errorf("cannot run unsquashfs: %v", osutil.OutputErr(output, err))
        }